<template>
  <div>
    <el-input readonly placeholder="请选择用户" :value="selectUser">
      <el-button slot="append" icon="el-icon-search" @click="open()"></el-button>
    </el-input>
    <UserSelectDialog :value="value" ref="UserSelectDialog" @confirm="confirm"></UserSelectDialog>
  </div>

</template>
<script>
  import UserSelectDialog from './UserSelectDialog'
    export default {
      components:{
        UserSelectDialog
      },
        props: {
            value: {
                type: [String,Number],
                default() {
                    return ''
                }
            },
          extended: {
                type: Object,
                default() {
                    return {}
                }
            },
        },
        data() {
            return {
                selectUser: '',
            }
        },
        computed: {

        },
        watch: {
          extended(n){
           this.init()
          }
        },
        methods: {
          init(){
            if(this.extended.user){
              this.selectUser = `${this.extended.user.nickName}(${this.extended.user.userName})`
            }
          },
            confirm(user) {
                this.$emit('change', user)
                this.$emit('input', user.userId)
            },
            open() {
              this.$refs.UserSelectDialog.show()
            }
        },
        created() {

        },
        mounted() {

        },
    }
</script>
